// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   CopyDir.java

package include.nseer_cookie;

import java.io.File;

// Referenced classes of package include.nseer_cookie:
//			copyFile, delFile

public class CopyDir
{

	public CopyDir()
	{
	}

	public void cp(String sourcepath, String destpath)
	{
		File sfile = new File(sourcepath);
		File dfile = new File(destpath);
		File slist[] = sfile.listFiles();
		File dlist[] = dfile.listFiles();
		int sl = slist.length;
		int dl = dlist.length;
		int fileno = 0;
		String tempName = "";
		if (dlist.length == 0)
		{
			fileno = 1;
		} else
		{
			for (int j = 0; j < dl; j++)
				if (!dlist[j].isDirectory())
				{
					tempName = dlist[j].getName();
					if (!tempName.substring(tempName.lastIndexOf(".")).equals(".db"))
					{
						tempName = tempName.substring(5, tempName.lastIndexOf("."));
						if (fileno < Integer.parseInt(tempName))
							fileno = Integer.parseInt(tempName);
					}
				}

			fileno++;
		}
		for (int j = 0; j < sl; j++)
			if (!slist[j].isDirectory())
			{
				tempName = slist[j].getName();
				tempName = tempName.substring(tempName.lastIndexOf("."));
				if (!tempName.equals(".db"))
				{
					copyFile cp = new copyFile((new StringBuilder(String.valueOf(sourcepath))).append("/").append(slist[j].getName()).toString(), (new StringBuilder(String.valueOf(destpath))).append("/nseer").append(fileno).append(tempName).toString());
					cp.setMakeDirs(false);
					cp.copy();
					fileno++;
				}
			}

		delFile df = new delFile();
		df.delete(sourcepath);
	}

	public static void main(String args[])
	{
		CopyDir cd = new CopyDir();
		cd.cp("D:/tomcat/webapps/erp/temp_object_dir/temp", "D:/tomcat/webapps/erp/nseerImages");
	}
}
